{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### $G = 1- \\sum_{i=1}^k p^2_i$ \n",
    "#### 和信息熵一样, 越大, 越不确定\n",
    "## Gini系数计算起来比 信息熵 略快"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6666666666666667\n",
      "0.4600000000000001\n",
      "3.999939999999036e-05\n"
     ]
    }
   ],
   "source": [
    "a = [1/3, 1/3, 1/3]\n",
    "b = [1/10, 2/10, 7/10]\n",
    "c = [0.99998, 0.00001, 0.00001]\n",
    "g_a = 1 - sum([i**2 for i in a])\n",
    "g_b = 1 - sum([i**2 for i in b])\n",
    "g_c = 1 - sum([i**2 for i in c])\n",
    "print(g_a, g_b, g_c, sep='\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn import datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "iris = datasets.load_iris()\n",
    "X = iris.data[:, 2:]\n",
    "y = iris.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.tree import DecisionTreeClassifier"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=2,\n",
       "            max_features=None, max_leaf_nodes=None,\n",
       "            min_impurity_decrease=0.0, min_impurity_split=None,\n",
       "            min_samples_leaf=1, min_samples_split=2,\n",
       "            min_weight_fraction_leaf=0.0, presort=False, random_state=None,\n",
       "            splitter='best')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt_clf = DecisionTreeClassifier(max_depth=2, criterion='gini')\n",
    "dt_clf.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_decision_boundary(model, axis):\n",
    "    x0, x1 = np.meshgrid(\n",
    "        np.linspace(axis[0], axis[1], int((axis[1]-axis[0])*100)),\n",
    "        np.linspace(axis[2], axis[3], int((axis[3]-axis[2])*100))\n",
    "    )\n",
    "    x_new = np.c_[x0.ravel(), x1.ravel()]\n",
    "    \n",
    "    y_predict = model.predict(x_new)\n",
    "    zz = y_predict.reshape(x0.shape)\n",
    "    from matplotlib.colors import ListedColormap\n",
    "    custom_cmap = ListedColormap(['#EF9A9A', '#FFF59D', '#90CAF9'])\n",
    "    plt.contourf(x0, x1, zz, linewidth=5, cmap=custom_cmap)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\fangyang\\Anaconda3\\lib\\site-packages\\matplotlib\\contour.py:967: UserWarning: The following kwargs were not used by contour: 'linewidth'\n",
      "  s)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAHBhJREFUeJzt3XuQXOV55/HvMxckNBohbElIgECmIDaYDWBmZWztuqjYYUGijIuYXXlrvbHLFW1lDQu7rtpacAowa4ektsqOynjjUoANJCzEXOwoQcTEZSdcHC4jWcSA2DKLzUqRYADdRjfQzDz7R5+Z6Tlzevrt7tN9Lv37VE3R5+33nH4kSo+Ozvn1e8zdERGRcunJugAREUmfmruISAmpuYuIlJCau4hICam5i4iUkJq7iEgJ1W3uZjbfzJ4zs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ZnY6sA64M+tauo2ZLQI+QSV9h7u/V8TGHvkk8H+zauxQwuZeJma2CrgIeDbbSsJFlzS2AyPA37p7YWqP/BHwX4H4Yv5F4cDjZrY1Wu6jSM4C3gL+V3RZ7E4zG8i6qCatB+7PsgA195wys4XAw8AN7n4w63pCufu4u19I5ZvMq82sMJfGzOxKYMTdt2ZdSwvWuPtHqKzi+uXoMmVR9AEfAf7Y3S8CDgP/LduSGhddTvo08GCWdai551B0vfph4D53fyTrepoR/XP674DLMy6lEWuAT0fXrR8AfsPM/jzbkhrj7ruj/44A36eyqmtR7AJ2Vf1r7yEqzb5orgC2ufubWRah5p4z0U3Ju4Ad7v7NrOtphJktNbPF0esTgU8Br2RbVTh3v9HdT3f3VVT+Wf1jd/93GZcVzMwGopvwRJczLgMKkxpz9zeAnWb2wWjok0DugwQJPkfGl2Qg8ElMRWJm9wOXAkvMbBdwi7vflW1VDVkDfB74eXTtGuAmd9+SYU2hVgD3REmBHuB77l64OGGBnQJ8P3qUQh/wv939b7ItqWHXAfdFlzZeA76YcT0NMbMFwG8C/yHzWsoWhRQREV2WEREpJTV3EZESUnMXESkhNXcRkRJScxcRKSE1dxGRElJzFxEpof8PD4I4mMhFbdkAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1b294aadc88>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(dt_clf, axis=[0.5, 7.5, 0,3])\n",
    "plt.scatter(X[y==0,0],X[y==0,1])\n",
    "plt.scatter(X[y==1,0],X[y==1,1])\n",
    "plt.scatter(X[y==2,0],X[y==2,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 模拟使用基尼系数进行划分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
